Video data enhancement method

ABSTRACT

A method for enhancing video data includes inputting image data, providing a first threshold, generating a first mean gray level, generating a first minimum gray level, generating a first maximum gray level, generating a second mean gray level, generating a second minimum gray level, and generating a second maximum gray level. According to the first threshold, generate a second threshold, a third mean gray level, and a fourth mean gray level. According to the third mean gray level, the first gray level, and the first minimum gray level, generate a first gain. According to the fourth mean gray level, the second mean gray level, and the second minimum gray level, generate a second gain. Finally, according to the first mean gray level, the first gain, the third mean gray level, the second mean gray level, the second gain, and the fourth mean gray level; generate enhanced image data.

BACKGROUND OF INVENTION

1. Field of the Invention

The invention relates to video data enhancement, and more particularly,to a method for segmented processing of the intensity distribution ofimage graphic data.

2. Description of the Prior Art

Please refer to FIG. 1 and FIG. 2. FIG. 1 shows a block diagram of animage processing system 10 according to the prior art, and FIG. 2 showsan image graphic 14 processed by the image processing system 10. Theimage processing system 10 includes a memory 12 for storing programs,the image graphic 14 awaiting processing, and a processing unit 16 forexecuting the programs stored in the memory 12. The image graphic 14 hasa plurality of pixels 18 arranged in matrix form and includes a region20 having a predefined feature.

Please refer to FIG. 3. FIG. 3 shows an intensity histogram for theimage graphic 14. The pixels 18 in the image graphic 14 are eachassigned a gray level, and the intensity histogram shown in FIG. 3graphs the number of pixels 18 in the image graphic 14 that are at eachgray level. According to the prior art, image processing involves usingthe intensity histogram to select a maximum gray level and a minimumgray level and then performing an image processing operation on thepixels having gray levels falling between the maximum gray level and theminimum g ray level.

Please refer to FIG. 4 and FIG. 5. FIG. 4 shows a transform function forpixels in the image graphic 14, where the horizontal axis represents theoriginal gray level of the pixels before transformation and the verticalaxis represents the gray level of the pixel after being transformed bythe transform function. From FIG. 4 it can be seen that thetransformation process involves first selecting a pixel 14 having a graylevel being between the maximum gray level and the minimum gray level,and then using a linear transformation function to convert the originalgray level for the pixel to an adjusted gray level being from 0 to 255.FIG. 5 shows an intensity histogram of the image graphic 14 after beingprocessed with the transformation function shown in FIG. 4. From FIG. 5it can be seen that the pixels having original gray levels between themaximum gray level and the minimum gray level have now been distributedbetween gray level 0 and gray level 255. The intensity histogram of theimage graphic 14 after being processed is therefore more evenlydispersed when compared with the original intensity histogram shown inFIG. 3.

The goal of image processing is to enhance the predefined feature of theregion 20 in the image graphic 14 and to increase the difference betweenthe region 20 and the image background. The image processing techniqueexplained above operates on and adjusts the parameters of the graphicimage 14 as a whole. For this reason, the image processing techniqueaccording to the prior art is only capable of enhancing a primary blockin the image graphic and is therefore not able to effectively increasethe difference between the region 20 having the predefined feature andthe image background. This remains as a problem to be solved.

SUMMARY OF INVENTION

It is therefore a primary objective of the claimed invention to providea method for image data enhancement, to solve the above-mentionedproblem.

According to the claimed invention, a method is disclosed for enhancingvideo image data. The method comprises the following steps: (a)inputting image data having a plurality of pixels; (b) providing a firstgray level range and a second gray level range; according to theplurality of pixels in the image data being within the first gray levelrange, generating a first mean gray level, a first minimum gray level, afirst maximum gray level; and according to the plurality of pixels inthe image data being within the second gray level range, generating asecond mean gray level, a second minimum gray level, and a secondmaximum gray level; wherein the boundary between the first gray levelrange and the second gray level range is a first threshold; (c)according to the first threshold, generating a second threshold;according to the second threshold, the first mean gray level, the firstminimum gray level, and the first maximum gray level, generating a thirdmean gray level; and according to the second threshold, the second meangray level, the second minimum gray level, and the second maximum graylevel, generating a fourth mean gray level; (d) according to the thirdmean gray level, the first mean gray level, and the first minimum graylevel, generating a first gain value; and according to the fourth meangray level, the second mean gray level, the second minimum gray level,generating a second gain value; and (e) according to the first mean graylevel, the first gain value, the third mean gray level, the second meangray level, the second gain value, and the fourth mean gray level,generating adjusted image data gray levels for the first gray levelrange and the second gray level range.

These and other objectives of the claimed invention will no doubt becomeobvious to those of ordinary skill in the art after reading thefollowing detailed description of the preferred embodiment that isillustrated in the various figures and drawings.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a block diagram of an image processing system according to theprior art.

FIG. 2 is an image graphic to be processed by the image processingsystem of FIG. 1.

FIG. 3 is an intensity histogram for the image graphic of FIG. 1.

FIG. 4 is a pixel transform function used by the image processing systemof FIG. 1.

FIG. 5 is an intensity histogram of the image graphic after beingprocessed using the pixel transformation function shown in FIG. 4.

FIG. 6 is a block diagram of an image processing system according to thepresent invention.

FIG. 7 is a flowchart describing a first method of image processingaccording to a first embodiment of the present invention.

FIG. 8 is a flowchart describing a second method of image processingaccording to a second embodiment of the present invention.

DETAILED DESCRIPTION

Please refer to FIG. 6. FIG. 6 shows a block diagram of an imageprocessing system 30 according to the present invention and includes amemory 32 for storing an image processing program 34 and an imagegraphic 36 waiting to be processed. The image processing system 30further includes an image processor 38 for executing the imageprocessing program 34 stored in the memory 32 and a user interface inputdevice 40 allowing the user to control and configure parameter settings.

Please refer to FIG. 7. FIG. 7 shows a flowchart describing a firstmethod of image processing according to a first embodiment of thepresent invention and includes the following steps:

Step 100:Calculate an intensity histogram for the image graphic 36including the number of pixels at each gray level and a total number ofpixels (Total_T) for the whole image graphic 36.

Step 102:Provide a first threshold (Tp) and according to the firstthreshold (Tp) generate a second threshold (NewTp), a first pixel count(Vleft) being the number of pixels in the image graphic 36 having a graylevel from gray level 0 to the first threshold (Tp), a first mean graylevel (L_oldmean) being the mean gray level of the first pixel count(Vleft), a second pixel count (Vright) being the number of pixels in theimage graphic 36 having a gray level from the first threshold (Tp) togray level 255, and a second mean gray level (R_oldmean) being the meangray level of the second pixel count (Vright).

Step 104:Provide a cutoff percentage (Cut_rate). According to the cutoffpercentage (Cut_rate), generate a first minimum gray level (L_min_end)being the gray level of the nth pixel when accumulating the pixels inorder of increasing gray levels starting at gray level 0, wherein n isequal to the cutoff percentage (Cut_rate) multiplied by the total numberof pixels (Total_T); and a first maximum gray level (L_max_end) beingthe gray level of the n^(th) pixel when accumulating the pixels in orderof decreasing gray levels starting at the first threshold (Tp), whereinn is equal to the cutoff percentage (Cut_rate) multiplied by the totalnumber of pixels (Total_T). Using the same logic, further generate asecond minimum gray level (R_min_end) being the gray level of the n^(th)pixel when accumulating the pixels in order of increasing gray levelsstarting at the first threshold (Tp), wherein n is equal to the cutoffpercentage (Cut_rate) multiplied by the total number of pixels(Total_T); and a second maximum gray level (R_max_end) being the graylevel of the nth pixel when accumulating the pixels in order ofdecreasing gray levels starting at the gray level 255, wherein n isequal to the cutoff percentage (Cut_rate) multiplied by the total numberof pixels (Total_T).

Step 106:Provide a first tolerance value (TH_bound). If the differencebetween the first pixel count (Vleft) and the second pixel count(Vright) is less than the tolerance value (TH_bound), proceed to step108. If the difference when the second pixel count (Vright) issubtracted from the first pixel count (Vleft) is greater than thetolerance value TH_bound, proceed to step 110. Otherwise, if thedifference when the first pixel count (Vleft) is subtracted from thesecond pixel count (Vright) is greater than the tolerance value(TH_bound), proceed to step 112.

Step 108:If the difference between the first pixel count (Vleft) and thesecond pixel count (Vright) is less than the tolerance value (TH_bound),set the second threshold (NewTp) equal to the first threshold (Tp).Proceed to step 114.

Step 110:If the difference when the second pixel count (Vright) issubtracted from the first pixel count (Vleft) is greater than thetolerance value TH_bound, set the second threshold (NewTp) equal to thegray level of the nth pixel when accumulating the pixels in order ofincreasing gray levels starting at the first threshold (Tp), wherein nis equal to the cutoff percentage (Cut_rate) multiplied by the totalnumber of pixels (Total_T). Proceed to step 114.

Step 112:If the difference when the first pixel count (Vleft) issubtracted from the second pixel count (Vright) is greater than thetolerance value (TH_-bound), set the second threshold (NewTp) equal tothe gray level of the n^(th) pixel when accumulating the pixels in orderof decreasing gray levels starting at the first threshold (Tp), whereinn is equal to the cutoff percentage (Cut_rate) multiplied by the totalnumber of pixels (Total_T). Proceed to step 114.

Step 114:According to the second threshold (NewTp), the first mean graylevel (L_oldmean), the first minimum gray level (L_min_end), and thefirst maximum gray level (L_max_end), generate a third mean gray level(L_newmean). According to the second threshold (NewTp), the second meangray level (R_oldmean), the second minimum gray level (R_min_end), andthe second maximum gray level (R_max_end), generate a fourth mean graylevel (R_newmean). Wherein the third mean gray level (L_newmean) isequal to (NewTp*(L_oldmean L_min_end)/(L_max_end L_min_end), and thefourth mean gray level (R_newmean) is equal to (255 NewTp)*(R_oldmeanR_min_end)/(R_max_end R_min_end)+NewTp.

Step 116:According to the third mean gray level (L_newmean), the firstmean gray level (L_oldmean), and the first minimum gray level(L_min_end), generate a first gain value (L_Gain). According to thefourth mean gray level (R_newmean), the second mean gray level(R_oldmean), and the second minimum gray level (R_min_end), generate asecond gain value (R_Gain). Wherein the first gain value (L_Gain) isequal to L_newmean/(L_oldmean L_min_end), and the second gain value(R_Gain) is equal to (R_newmean NewTp)/(R_oldmean R_min_end).

Step 118:According to the first mean gray level (L_oldmean), the firstgain value (L_Gain), the third mean gray level (L_newmean), the secondmean gray level (R_oldmean), the second gain value (R_Gain), and thefourth mean gray level (R_newmean), generate adjusted image data graylevels. In order to generate adjusted image data gray levels for pixelsbeing less than the second threshold (NewTp), the difference of theoriginal gray level of each pixel having a gray level being less thanthe second threshold (NewTp) and the first mean gray level (L_oldmean)is multiplied with the first gain value (L_Gain) and added to the thirdmean gray level (L_newmean). In order to generate adjusted image datagray levels for pixels being greater than the second threshold (NewTp),the difference of the original gray level of each pixel having a graylevel being greater than the second threshold (NewTp) and the secondmean gray level (R_newmean) is multiplied with the second gain value(R_Gain) and added to the fourth mean gray level (R_newmean). Finally,combine the adjusted image data gray levels for pixels being less thanthe second threshold (NewTp) and the adjusted image data gray levels forpixels being greater than the second threshold (NewTp) to generateadjusted gray levels for the entire image graphic 36.

A further description of the above steps is as follows. In step 100,statistics can be used to integrate the pixel counts for each gray levelin the intensity histogram (not described in this document) anddetermine the total number of pixels (Total_T). In other words, thetotal number of pixels (Total_T) is the area under the curve in theintensity histogram. In step 102, the first threshold (Tp) can be inputusing a user interface. For example, a scroll bar could be used to setthe size of the first threshold (Tp) or the first threshold (Tp) couldbe directly entered using the input device. Alternatively, in anotherembodiment, the product of the first threshold (Tp) and a firstweighting factor is added to the product of a mean gray level for theentire image graphic 36 and a second weighting factor, wherein the sumof the first weighting factor and the second weighting factor is 1. Thefirst weighting factor and the second weighting factor account forwhether the original image data on a whole is biased dark, biasedbright, or biased normally. In step 102, statistics can again be used todetermine the area under the image intensity histogram from gray level 0to the first threshold (Tp) for the image graphic 36, generate the firstpixel count (Vleft), and calculate the first mean gray level(L_oldmean). Similar logic can be used to find the area under the imageintensity histogram from the first threshold (Tp) to gray level 255 forthe image graphic 36, generate the second image count (Vright), andcalculate the second mean gray level (R_oldmean).

In step 104, the cutoff percentage (Cut_rate) is used to select an areain which the image processing will take place. For example, if thecutoff percentage (Cut_rate) is 5%, this represents two cutoff regionslocated on the two ends of the image intensity histogram, each cutoffregion being 5% of the total number of pixels. In this case, the firstminimum gray level (L_min_end) is the gray level of the nth pixel whenaccumulating the pixels in order of increasing gray levels starting atgray level 0, where n is equal to the cutoff percentage (5%) multipliedby the total number of pixels (Total_T). And the first maximum graylevel (L_max_end) is the gray level of the nth pixel when accumulatingthe pixels in order of decreasing gray levels starting at the firstthreshold (Tp), where n is equal to the cutoff percentage (5%)multiplied by the total number of pixels (Total_T). Using similar logic,the second minimum gray level (R_min_end) is the gray level of then^(th) pixel when accumulating the pixels in order of increasing graylevels starting at the first threshold (Tp), where n is equal to thecutoff percentage (5%) multiplied by the total number of pixels(Total_T). And the second maximum gray level (R_max_end) is the graylevel of the n^(th) pixel when accumulating the pixels in order ofdecreasing gray levels starting at gray level 255, where n is equal tothe cutoff percentage (5%) multiplied by the total number of pixels(Total_T). It should be noted that the cutoff percentage (Cut_rate) canbe a preset parameter of the image processing program 34 or can be auser-selectable parameter input using the user interface input device40. Furthermore, the present invention is not restricted to using theabove-mentioned technique of multiplying the cutoff percentage(cut_rate) by the total number of pixels (Total_T) in order to determinethe cutoff area. Other techniques can also be used such as allowing theuser to directly specify the cutoff area using the user interface inputdevice 40.

In step 106, the tolerance value (TH_bound) is used to compare the twopixel counts determined using the first threshold (Tp) and thereby judgewhether to automatically switch to normal, biased dark, or biased brightimage processing. In the first embodiment of the present invention, ifthe difference between the first pixel count (Vleft) and the secondpixel count (Vright) is less than the tolerance value (TH_bound), it isnot necessary to display the image graphic 36 particularly brightened orparticularly darkened. In this case, normal image processing can be usedto enhance the image as a whole. If the difference when the second pixelcount (Vright) is subtracted from the first pixel count (Vleft) isgreater than the tolerance value (TH_bound), proceed to step 110. Inthis case, because the first threshold (Tp) left side pixel count isgreater than the right side pixel count and the difference exceeds thetolerance value (TH_bound), the image graphic 36 is biased dark andbiased dark image processing is used to enhance the biased dark area ofthe image. In step 110, the new threshold is determined by moving theoriginal first threshold (Tp) to the right to form the second threshold(NewTp). In other words, the darker area (the area having the lower graylevels) is increased in size and then image processed. If the differencewhen the first image count (Vleft) is subtracted from the second imagecount (Vright) is greater than the tolerance value (TH_bound) proceed tostep 112. In this case, because the first threshold (Tp) right sidepixel count is greater than the left side pixel count and the differenceexceeds the tolerance value (TH_bound), the image graphic 36 is biasedbright and biased bright image processing is used to enhance the biasedbright area of the image. In step 112, the new threshold is determinedby moving the original first threshold (Tp) to the left to form thesecond threshold (NewTp). In other words, the lighter area (the areahaving the higher gray levels) is increased in size and then imageprocessed. It should also be noted that the second threshold (NewTp)determined in steps 110 and 112 could also be input from the user. It isnot a required limitation of the present invention that the cutoffpercentage (Cut_rate) is multiplied by the total number of pixels(Total_T) in order to determine the second threshold.

The present invention therefore judges if the image is biased normally,biased dark, or biased bright and then automatically selects the type ofimage processing being either normal processing, biased dark processing,or biased bright processing. The user can also directly select whetherto use normal processing, biased dark processing, or biased brightprocessing by using the user interface input device 40 to select “normalprocessing”, “biased dark processing”, “biased bright processing”, or“automatic processing”. These selections can be located on four separatebuttons allowing the user to choose the image processing mode. Accordingto the image processing mode command received, the image processingsystem 30 switches to the corresponding image processing type. Forexample, if the user pushes the “normal processing” button, normalprocessing mode will be selected and operations will proceed to step108. If the user pushes the “biased dark processing” button, biased darkprocessing mode will be selected and operations will proceed to step110. If the user pushes the “biased bright processing” button, biasedbright processing mode will be selected and operations will proceed tostep 112. Finally, if the user pushes the “automatic processing” button,automatic processing mode will be selected and operations will proceedto step 106 where according to the judgment made in step 106, eithernormal processing mode, biased dark processing mode, or biased brightprocessing mode will be used.

In step 114, step 116, and step 118, the adjusted image data gray levelscan be generated as follows. For pixels having gray levels less than thesecond threshold (NewTP), the adjusted image data gray levels are:(original gray levels of pixels less than the second threshold NewTp thefirst mean gray level L_oldmean)*(the first gain value L_gain)+(thethird mean gray level L_newmean). For pixels having gray levels greaterthan the second threshold (NewTp), the adjust image data gray levelsare: (the original gray levels of the pixels greater than the secondthreshold NewTp the second mean gray level R_oldmean)*(the second gainvalue R_Gain)+(the fourth mean gray level R_newmean). Finally, combinethe adjusted image data gray levels for the pixels having gray levelsless than the second threshold (NewTp) and for the pixels having graylevels larger than the second threshold (NewTp) to generate adjustedimage data gray levels for the whole image graphic 36.

If a more smoothed image enhancement result is desired, the originalgray levels of the image data can be multiplied by a third weightingfactor and then added to the adjusted image data gray levels generatedin step 118 multiplied by the first weighting factor to generate finaladjusted image data gray levels, wherein the third weighting factor andthe first weighting factor sum to a value of 1.

Please refer to FIG. 8. FIG. 8 shows a flowchart describing a secondmethod of image processing according to a second embodiment of thepresent invention and comprises the following steps:

Step 120:Calculate an image intensity histogram for the image graphic36, calculate the number of pixels for each gray level in the imagegraphic 36, and calculate the total number of pixels in the imagegraphic 36.

Step 122:Provide a first gray level range and a second gray level range.According to the plurality of pixels in the image data being within thefirst gray level range, generate a first mean gray level, a firstminimum gray level, and a first maximum gray level. According to theplurality of pixels in the image data being within the second gray levelrange, generate a second mean gray level, a second minimum gray level,and a second maximum gray level. Wherein the boundary between the firstgray level range and the second gray level range is a first threshold.

Step 124:According to the first threshold, generate a second thresholdand according to the second threshold, the first mean gray level, thefirst minimum gray level, and the first maximum gray level, generate athird mean gray level. According to the second threshold, the secondmean gray level, the second minimum gray level, and the second maximumgray level, generate a fourth mean gray level.

Step 126:According to the third mean gray level, the first mean graylevel, and the first minimum gray level, generate a first gain value.According to the fourth mean gray level, the second mean gray level, andthe second minimum gray level, generate a second gain value.

Step 128:According to the first mean gray level, the first gain value,the third mean gain value, the second mean gray level, the second gainvalue, and the fourth mean gray level, generate adjusted image data graylevels for the first gray level range and the second gray level range.

Step 130:Provide a third gray level range and a fourth gray level range.According to the plurality of pixels in the image data being within thethird gray level range, generate a fifth mean gray level, a thirdminimum gray level, and a third maximum gray level. According to theplurality of pixels in the image data being within the second gray levelrange, generate a sixth mean gray level, a fourth minimum gray level,and a fourth maximum gray level. Wherein the boundary between the thirdgray level range and the fourth gray level range is a third threshold.

Step 132:According to the third threshold, generate a fourth thresholdand according to the fourth threshold, the fifth mean gray level, thethird minimum gray level, and the third maximum gray level, generate aseventh mean gray level. According to the fourth threshold, the sixthmean gray level, the fourth minimum gray level, and the fourth maximumgray level, generate an eighth mean gray level.

Step 134:According to the seventh mean gray level, the fifth mean graylevel, and the third minimum gray level, generate a third gain value.According to the eighth mean gray level, the sixth mean gray level, andthe fourth minimum gray level, generate a fourth gain value.

Step 136:According to the fifth mean gray level, the third gain value,the seventh mean gray level, the sixth mean gray level, the fourth gainvalue, and the eighth mean gray level, generate adjusted image data graylevels for the third gray level range and adjusted image data graylevels for the fourth gray level range.

Step 138:Combine the adjusted image data for the first gray level rangeand the second gray level range with the adjusted pixel data for thethird gray level range and the fourth gray level range to produce adjustgray levels for the whole image graphic 36.

The basic idea behind the second embodiment of the present invention isthe same as the technique in the first embodiment, however, the secondembodiment divides the image graphic 36 into 4 different segments: thefirst gray level range, the second gray level range, the third graylevel range, and the fourth gray level range. The image processingtechnique for each segment is the same as described for the firstembodiment and a repeated description is therefore omitted. The adjustedimage data gray levels for the four different segments are then combinedto form adjusted image data gray levels for the image graphic 36.

Besides the two embodiments previously described that divide the imagegraphic 36 into two ranges or four segments, or other embodiments thatdivide the image graphic into another number of segments and thenperform image enhancement on each range, it is also possible to use theimage intensity histogram to determine ranges having special orsignificant features. Segmented processing can then be performed foreach range or segment using the image processing technique describedherein.

In contrast to the prior art, the method of image enhancement accordingto the present invention is a segmented image intensity distributionadjustment method using rules to enhance the video image data. Becausethe present invention includes normal processing mode, biased darkprocessing mode, biased bright processing mode, and automatic processingmode; video taken in poor lighting conditions, video taken at night, andin normal lighting conditions are all noticeable improved. Furthermore,besides normal image processing, the present invention can also be usedin high speed processing systems (real time) to provide imageenhancement. For example, the video data received by surveillance videocamera recorders and equipment, digital video cameras, and digital videorecorders can all be enhanced by the present invention in real time.Additionally, because the present invention automaticallyjudges whetherthe image is biased dark, biased normally, or biased bright, a moreeffective image enhancement is performed when compared with the priorart. Also, the present invention does not only do image enhancement tothe whole image or a region of the image and neglect enhancing thedifference between the region having a predefined feature and the imagebackground. The present invention can be used at night, or lowlight/non-optimal light conditions to enhance the clearness andsharpness of the video image and enhance the difference with thebackground.

Those skilled in the art will readily observe that numerousmodifications and alterations of the device may be made while retainingthe teachings of the invention. Accordingly, the above disclosure shouldbe construed as limited only by the metes and bounds of the appendedclaims.

1. A method for enhancing video image data, the method comprising thefollowing steps: (a) inputting image data having a plurality of pixels;(b) providing a first gray level range and a second gray level range;according to the plurality of pixels in the image data being within thefirst gray level range, generating a first mean gray level, a firstminimum gray level, a first maximum gray level; and according to theplurality of pixels in the image data being within the second gray levelrange, generating a second mean gray level, a second minimum gray level,and a second maximum gray level; wherein the boundary between the firstgray level range and the second gray level range is a first threshold;(c) according to the first threshold, generating a second threshold;according to the second threshold, the first mean gray level, the firstminimum gray level, and the first maximum gray level, generating a thirdmean gray level; and according to the second threshold, the second meangray level, the second minimum gray level, and the second maximum graylevel, generating a fourth mean gray level; (d) according to the thirdmean gray level, the first mean gray level, and the first minimum graylevel, generating a first gain value; and according to the fourth meangray level, the second mean gray level, the second minimum gray level,generating a second gain value; and (e) according to the first mean graylevel, the first gain value, the third mean gray level, the second meangray level, the second gain value, and the fourth mean gray level,generating adjusted image data gray levels for the first gray levelrange and the second gray level range.
 2. The method of claim 1, whereinstep (b) further comprises according to the first threshold, generatinga first pixel count being the total number of image data pixels beingbetween gray level 0 and the first threshold, and generating a secondpixel count being the total number of image data pixels being betweenthe first threshold and gray level 255; wherein the first mean graylevel is the average gray level of the first pixel count, and the secondmean gray level is the average gray level of the second pixel count. 3.The method of claim 1, further comprising providing a cutoff percentage;wherein the first minimum gray level, the first maximum gray level, thesecond minimum gray level, and the second maximum gray level aregenerated also according to the cutoff percentage.
 4. The method ofclaim 3, wherein in step (b), the first minimum gray level is the graylevel of the n^(th) pixel when accumulating the pixels in order ofincreasing gray levels starting at gray level 0, n being equal to thecutoff percentage multiplied by the total number of pixels; the firstmaximum gray level is the gray level of the n^(th) pixel whenaccumulating the pixels in order of decreasing gray levels starting atthe first threshold, n being equal to the cutoff percentage multipliedby the total number of pixels; the second minimum gray level is the graylevel of the n^(th) pixel when accumulating the pixels in order ofincreasing gray levels starting at the first threshold, n being equal tothe cutoff percentage multiplied by the total number of pixels; and thesecond maximum gray level is the gray level of the n^(th) pixel whenaccumulating the pixels in order of decreasing gray levels starting atgray level 255, n being equal to the cutoff percentage multiplied by thetotal number of pixels.
 5. The method of claim 1, wherein step (c)further comprises providing a tolerance value; if the difference betweenthe first pixel count and the second pixel count is less than thetolerance value, setting the second threshold equal to the firstthreshold; if the difference when the second pixel count is subtractedfrom the first pixel count exceeds the tolerance value, setting thesecond threshold to the gray level of the n^(th) pixel when accumulatingthe pixels in order of increasing gray levels starting at the firstthreshold, wherein n is equal to the cutoff percentage multiplied by thetotal number of pixels; and if the difference when the first pixel countis subtracted from the second pixel count exceeds the tolerance value,setting the second threshold to the gray level of the nth pixel whenaccumulating the pixels in order of decreasing gray levels starting atthe first threshold, wherein n is equal to the cutoff percentagemultiplied by the total number of pixels.
 6. The method of claim 4,wherein in step (c), the third mean gray level is: (the secondthreshold)*(the first mean gray level the first minimum gray level)/(thefirst maximum gray level the first minimum gray level); and the fourthmean gray level is: (255 the second threshold)*(the second mean graylevel the second minimum gray level)/(the second maximum gray level thesecond minimum gray level)+the second threshold.
 7. The method of claim1, wherein in step (d), the first gain value is: (the third mean graylevel)/(the first mean gray level the first minimum gray level); and thesecond gain value is: (the fourth mean gray level the secondthreshold)/(the second mean gray level the second minimum gray level).8. The method of claim 1, wherein step (e) comprises multiplying thedifference between the original gray level of pixels being less than thesecond threshold and the first mean gray level with the first gainvalue, and then adding the third mean gray level to generate adjustedimage data gray levels for pixels less than the second threshold;multiplying the difference between the original gray level of pixelsbeing greater than the second threshold and the second mean gray levelwith the second gain value, and then adding the fourth mean gray levelto generate adjusted image data gray levels for pixels greater than thesecond threshold; and combining the adjusted image data gray levels forpixels less than and greater than the second threshold to generateadjusted gray levels for the image data.
 9. The method of claim 1,wherein the first threshold is input from a user interface.
 10. Themethod of claim 9, wherein the first threshold is the product of athreshold input from the user interface multiplied by a first weightingfactor added to the product of a mean gray level of all the pixels ofthe original image data multiplied by a second weighting factor.
 11. Themethod of claim 10, wherein the sum of the first weighting factor andthe second weighting factor is
 1. 12. The method of claim 1, furthercomprising generating final adjusted image data gray levels by addingthe product of the original image data gray levels and a third weightingfactor to the product of the adjusted image data gray levels generatedin step (e) and a fourth weighting factor.
 13. The method of claim 12,wherein the sum of the third weighting factor and the fourth weightingfactor is
 1. 14. The method of claim 1, further comprising the followingsteps: (f) providing a third gray level range and a fourth gray levelrange; according to the plurality of pixels in the image data beingwithin the third gray level range, generating a fifth mean gray level, athird minimum gray level, and a third maximum gray level; and accordingto the plurality of pixels in the image data belonging to the fourthgray level range, generating a sixth mean gray level, a fourth minimumgray level, and a fourth maximum gray level; wherein the boundarybetween the third gray level range and the fourth gray level range is athird threshold; (g) according to the third threshold, generating afourth threshold; according to the fourth threshold, the fifth mean graylevel, the third minimum gray level, and the third maximum gray level,generating a seventh mean gray level; and according to the fourththreshold, the sixth mean gray level, the fourth minimum gray level, andthe fourth maximum gray level, generating an eighth mean gray level; (h)according to the seventh mean gray level, the fifth mean gray level, andthe third minimum gray level, generating a third gain value; andaccording to the eighth mean gray level, the sixth mean gray level, andthe fourth minimum gray level, generating a fourth gain value; and (i)according to the fifth mean gray level, the third gain value, theseventh mean gray level, the sixth mean gray level, the fourth gainvalue, and the eighth mean gray level, generating adjusted image datagray levels for the third gray level range and the fourth gray levelrange.
 15. An image processing system using the method of claim 1.